home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1989 September / 1989-09.d64 / block battle (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  6KB  |  169 lines

  1. 5 rem copyright 1989 compute! publications, inc. - all rights reserved
  2. 10 goto1310
  3. 20 w=.:gf=w:yf=w:forz=wto5:ifp(z,7)=1thengf=gf+1
  4. 30 ifp(z,.)=2thenyf=yf+1
  5. 40 next:ifgf=6oryf=6thenw=p:return
  6. 50 ifgt=.andyt=.thenw=3:return
  7. 60 ifgt=.thenw=2:return
  8. 70 ifyt=.thenw=1:return
  9. 80 ifgf>=yfandgf>ytthenw=1:return
  10. 90 ifyf>=gfandyf>gtthenw=2:return
  11. 100 ifgf=yfandgt=yt andgf=gtthenw=3
  12. 110 return
  13. 120 poke646,19-p*6
  14. 130 l=len(m$):j=38-l/2:k=l-19:fori=1tok:poke214,22:print
  15. 140 printspc(j)left$(m$,i)right$(m$,l-(l-i)):j=j-1:next:return
  16. 150 pokev+41,1:gosub290:ife=1or(peek(56322-p)and16)=.goto210
  17. 160 ifx<.orx>7thenx=-7*(x<.)
  18. 170 ify<.ory>5theny=-5*(y<0)
  19. 180 ifx>5thenpokev+16,4:pokev+4,x*40-224:goto200
  20. 190 pokev+16,.:pokev+4,x*40+32
  21. 200 pokev+5,y*32+58:pokev+21,4:goto150
  22. 210 ifq=1andp(y,x)<>pthenr=1:goto280
  23. 220 ifq=2and(x=.orx=7)goto 150
  24. 230 m$="         indicate a direction        ":gosub120:a=x:b=y
  25. 240 gosub290:ifx=aandy=bgoto240
  26. 250 ifq=2goto280
  27. 260 ifx<.orx>7thenx=-7*(x>7)
  28. 270 ify<.ory>5theny=-5*(y>5)
  29. 280 pokev+21,.:return
  30. 290 jy=peek(56322-p)and15:g=peek(653):e=peek(197)
  31. 300 x=x+(jy=11)-(jy=7)+(g=1ande=2)-(g=.ande=2)
  32. 310 y=y+(jy=14)-(jy=13)+(g=1ande=7)-(g=.ande=7):return
  33. 320 d=32:ifr(b,a)=1thend=160
  34. 330 ifb(b,a)=1thend=224
  35. 340 gosub350:return
  36. 350 z=49193:goto 370
  37. 360 z=55337
  38. 370 f=z+a*5+b*160
  39. 380 pokef,d:pokef+1,d:pokef+2,d:pokef+40,d:pokef+41,d:pokef+42,d:return
  40. 390 f=49193+x*5+y*160:pokef,99:pokef+1,100:pokef+2,101:pokef+40,102
  41. 400 pokef+41,103:pokef+42,104:return
  42. 410 r=.:ifx<.orx>7ory<.ory>5thenr=1:return
  43. 420 ifxandx<>7andp(y,x)>.thenr=1:return
  44. 430 ifx=.andp=1andp(y,x)>.thenr=1
  45. 440 ifx=.andp=2andp(y,x)=2thenr=1
  46. 450 ifx=7andp=1andp(y,x)=1thenr=1
  47. 460 ifx=7andp=2andp(y,x)>.thenr=1
  48. 470 iftr>1andxandx<>7andb(y,x)=.andr(y,x)=.thenr=1
  49. 480 iftr>1thenreturn
  50. 490 ifxandx<>7and(b(y,x)=.orr(y,x)=.)thenr=1
  51. 500 return
  52. 510 p=2+(p=2):ifp=1orc<>1goto700
  53. 520 m$="          the computer moves         ":gosub120:tr=1
  54. 530 a=.:b=-1:iftr>2thena=int(6*rnd(1))
  55. 540 b=b+1:ifb>5thenb=.:a=a+1
  56. 550 ifa>7thentr=tr+1:goto530
  57. 560 ifp(b,a)<2goto 540
  58. 570 x=a:y=b:ifa=.theny=-1:goto640
  59. 580 y=b:x=a-1:gosub410:if r=.goto 690
  60. 590 iftr<3goto540
  61. 600 y=b-1:x=a:gosub410:ifr=.goto690
  62. 610 y=b+1:gosub410:ifr=.goto690
  63. 620 iftr<4goto680
  64. 630 y=b:x=x+1:gosub410:onr+1goto690,540
  65. 640 y=y+1:ify>5goto580
  66. 650 onp(y,x)+1goto640,660,640
  67. 660 ify>btheny=b+1:goto680
  68. 670 y=b-1
  69. 680 gosub410:onrgoto540
  70. 690 tr=1:goto720
  71. 700 m$="            choose a block           ":gosub120:q=1:y=1:x=(p-1)*7:r=.
  72. 710 gosub150:onrgoto700
  73. 720 tr=2:gosub410:onrgoto700
  74. 730 if p(y,x)=.goto760
  75. 740 ifp=1thenyt=yt-1:goto760
  76. 750 gt=gt-1
  77. 760 pokev+39,19-p*6:pokev+40,11
  78. 770 ifa>5thenpokev+16,3:pokev,a*40-224:pokev+2,a*40-224:goto790
  79. 780 pokev+16,.:pokev,a*40+32:pokev+2,a*40+32
  80. 790 pokev+1,b*32+58:pokev+3,b*32+58:pokev+21,3:ifaanda<>7thengosub320:goto810
  81. 800 d=106:gosub350:d=12:gosub360
  82. 810 p(b,a)=.:p(y,x)=p:i=a*40+32:k=b*32+58:forz=1to8
  83. 820 o=i+z*5*(x-a):if o>255 then poke v+16,3:pokev,o-256:pokev+2,o-256:goto840
  84. 830 pokev+16,.:pokev,o:pokev+2,o
  85. 840 o=k+z*4*(y-b):pokev+1,o:pokev+3,o:next
  86. 850 gosub390:d=19-p*6:f=f+6144:gosub380:pokev+21,.:gosub20:ifwgoto1250
  87. 860 ifp=1orc<>1goto1100
  88. 870 a=6:b=-1
  89. 880 b=b+1:ifb>5thenb=.:a=a-1
  90. 890 ifa=.goto1030
  91. 900 ifp(b,a)<>1goto880
  92. 910 ifb(b,a)>.andr(b,a)>.goto880
  93. 920 onr(b,a)goto980
  94. 930 y=b:x=a-1:if x<1 then x=6
  95. 940 ifb(y,x)=.thenx=a+1:goto1110
  96. 950 x=a+1:if x>6 then x=1
  97. 960 ifb(y,x)=.thenx=a-1:goto1110
  98. 970 goto880
  99. 980 y=b+1:x=a:ify>5theny=.
  100. 990 ifr(y,x)=.theny=b+1:goto1110
  101. 1000 y=b-1:ify<.theny=5
  102. 1010 ifr(y,x)=.theny=b-1:goto1110
  103. 1020 goto880
  104. 1030 a=2:b=-1
  105. 1040 b=b+1:ifb>5thenb=.:a=a+1
  106. 1050 ifa>7goto1090
  107. 1060 ifp(b,a)<2goto1040
  108. 1070 ifb(b,a-1)>.orr(b,a-1)>.goto1040
  109. 1080 a=a-1:x=a:y=b+1:goto1110
  110. 1090 a=2:b=5:x=1:y=b:goto1110
  111. 1100 m$="            choose a strip           ":gosub120:q=2:gosub150
  112. 1110 u=x-a:t=y-b:h=1:ifu=.thenh=.:goto1150
  113. 1120 ifu=1goto1140
  114. 1130 z=b(b,1):fora=1to5:b(b,a)=b(b,a+1):next:b(b,6)=z:goto1180
  115. 1140 z=b(b,6):fora=6to2step-1:b(b,a)=b(b,a-1):next:b(b,1)=z:goto1180
  116. 1150 ift=1goto1170
  117. 1160 z=r(.,a):forb=.to4:r(b,a)=r(b+1,a):next:r(5,a)=z:goto1180
  118. 1170 z=r(5,a):forb=5to1step-1:r(b,a)=r(b-1,a):next:r(.,a)=z
  119. 1180 forn=htoh+5:ifu=.thenb=n:goto1200
  120. 1190 a=n
  121. 1200 ifp(b,a)=.thengosub320:goto1240
  122. 1210 ifb(b,a)>.orr(b,a)>.goto1240
  123. 1220 d=32:gosub350:for z=8to72:poke53270,z:next
  124. 1230 gt=gt+(p(b,a)=1):yt=yt+(p(b,a)=2):p(b,a)=.
  125. 1240 next:gosub20:ifw=.goto510
  126. 1250 print"":onwgoto1270,1280
  127. 1260 m$="              tie game!              ":goto1300
  128. 1270 m$="          green player wins!         ":goto1300
  129. 1280 ifc=2thenm$="         yellow player wins!         ":goto1300
  130. 1290 m$="          the computer wins!         "
  131. 1300 gosub130:poke198,.:wait198,1:p=w:goto1500
  132. 1310 printchr$(142)chr$(8):x=rnd(-ti)
  133. 1320 poke781,9:poke782,1:poke90,.:poke91,216:poke88,.:poke89,248:poke56333,127
  134. 1330 poke1,51:sys41964:poke1,55:poke56333,129:poke56578,peek(56578)or3
  135. 1340 poke56576,peek(56576)and252:poke53272,peek(53272)and15:poke648,192
  136. 1350 poke53272,(peek(53272)and240)or12:print"[147]"
  137. 1360 m$="[158]          one moment please...      ":gosub120
  138. 1370 data255,255,255,255,245,250,245,250,255,255,255,255,85,170,85,170,255,254
  139. 1380 data252,248,80,160,80,160,245,250,245,250,240,224,192,128,85,170,85,170,,,
  140. 1390 data,80,160,80,160,,,,,245,250,245,250,245,250,245,250,85,170,85,170,85
  141. 1400 data170,85,170,80,160,80,160,80,160,80,160,255,255,255,128,,1,128,24,1,128
  142. 1410 data60,1,128,126,1,132,24,33,140,24,49,159,255,249,159,255,249,140,24,49
  143. 1420 data132,24,33,128,126,1,128,60,1,128,24,1,128,,1,255,255,255,,,,,,,,,,,,,
  144. 1430 data,,,255,255,255,255,255,254,255,255,252,255,255,248,245,85,80,250,170
  145. 1440 data160,245,85,80,250,170,160,245,85,80,250,170,160,245,85,80,250,170,160
  146. 1450 data240,,,224,,,192,,,128,,,,,,,,,,,,,,,,,,
  147. 1460 fora=.to71:readb:poke61720+a,b:next:forx=.to126:ready:poke62080+x,y:next
  148. 1470 forgf=.to47:poke62208+gf,255:next:foryf=.to14:poke62256+yf,.:next
  149. 1480 poke50168,203:poke50169,204:poke50170,202:a$="[163][164][164][164][165]":b$="[169]   [171]":c$="[166][167][167][167][168]"
  150. 1490 g$="[169][170][170][170][171]":v=53248:p=2
  151. 1500 fora=.to7:forb=.to5:r(b,a)=.:b(b,a)=.:p(b,a)=.:next:next
  152. 1510 poke53280,.:poke53281,.:poke53282,11:poke53284,6:poke53265,peek(53265)or64
  153. 1520 gt=6:yt=6:print"[147][145][145]";:forq=1to6:print"[152]"a$""a$a$a$a$a$a$"[152]"a$;
  154. 1530 printg$""b$b$b$b$b$b$"[152]"g$;:printg$""b$b$b$b$b$b$"[152]"g$;
  155. 1540 printc$""c$c$c$c$c$c$"[152]"c$;:next:forq=1to2:x=.:d=13:ifq=2thenx=7:d=7
  156. 1550 a=x:fory=.to5:p(y,x)=q:gosub390:b=y:gosub360:next:next:forx=1to6:c=.
  157. 1560 y=int(6*rnd(1)):onr(y,x)goto1560
  158. 1570 r(y,x)=1:a=x:b=y:d=160:gosub350:c=c+1:ifc<4goto1560
  159. 1580 next:fory=.to5:c=.
  160. 1590 x=int(6*rnd(1))+1:ifb(y,x)=1goto1590
  161. 1600 b(y,x)=1:a=x:b=y:d=224:gosub350:c=c+1:ifc<3goto1590
  162. 1610 next:print"":m$="             block battle!           ":gosub130
  163. 1620 gosub1670:m$="      copyright 1989 compute!        ":gosub130:gosub1670
  164. 1630 m$="         all rights reserved         ":gosub130:gosub1670
  165. 1640 m$="         [1] or [2] players?         ":gosub130
  166. 1650 poke198,0:wait198,1:getk$:c=val(k$):ifc<1orc>2goto1650
  167. 1660 goto510
  168. 1670 forz=1to1500:next:return
  169.